<template>
  <div class="flex flex-direction shichangjiandu">
    <div class="summary">
      <div class="title flex">
        <div class="title-icon">
          <img src="@/assets/images/shichangjiandu/data-icon.png">
          <span>案件列表</span>
        </div>
        <div class="title-bg">
          <img src="@/assets/images/shichangjiandu/data-bg.png">
        </div>
      </div>
      <div class="summary-content">
        <checked-title>
            <template #right>
                <div class="title2 pointer" :class="active == item.value ? 'active' : ''"
                    @click="tabChange(item.value)" v-for="(item, index) in tabList" :key="index">
                    <span class="state state1" v-if="item.value == 1"></span>
                    <span class="state state2" v-else-if="item.value == 3"></span>
                    <span class="state state3" v-else-if="item.value == 2"></span>
                    {{ item.title }}
                </div>
            </template>
        </checked-title>
        <CaseDetails ref="case"></CaseDetails>
        <div @click="workOrderDetails($event)" class="warp-box">
          <vue-seamless-scroll :class-option="classOption" :data="newList" class="warp" ref="mySwiper">
            <ul>
              <li :key="'a' + index" v-for="(item, index) in newList">
                <div class="latest_case">
                  <div class="latest_case_title">
                    <p>
                      <span class="state state1" v-if="item.state == 0"></span>
                      <span class="state state2" v-else-if="item.state == 1"></span>
                      <span class="state state3" v-else-if="item.state == 2"></span>
                      渠道来源：{{ item.sourceTitle }}
                    </p>
                    <p>时间：{{ item.selfDispatchTime }}</p>
                  </div>
                  <div class="latest_case_text ellipsis2">{{ item.content }}</div>
                  <div class="latest_case_weizhi">
                    <p>处置人：{{ item.disposerUserName }}</p>
                    <p>
                      <span :data-item="JSON.stringify(item)">查看详情</span>
                    </p>
                  </div>
                </div>
              </li>
            </ul>
          </vue-seamless-scroll>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
import vueSeamlessScroll from 'vue-seamless-scroll'
import CaseDetails from "@/components/caseDetails.vue";
import $ from 'jquery'

export default {
  components: {
    vueSeamlessScroll,
    CaseDetails
  },
  props: {
    classOption: {
      type: Object,
      default: () => { }
    },
    scrollData: {
      type: Array,
      default: () => []
    }
  },
  watch: {
    scrollData: function(newVal,oldVal){
      this.newList = newVal;
      let all = newVal.length
      let state0 = newVal.filter((item)=>{
        return item.state == 0
      }).length
      let state1 = newVal.filter((item)=>{
        return item.state == 1
      }).length
      let state2 = newVal.filter((item)=>{
        return item.state == 2
      }).length
      this.tabList = [
        { title: '全部 ' + all, value: '0' },
        { title: '处理中 ' + state0, value: '1' },
        { title: '即将超期 ' + state2, value: '2' },
        { title: '已超期 ' + state1, value: '3' },
      ]
    }
  },
  data() {
    return {
      newList: [],
      active: '0',
      tabList: [],
    }
  },
  computed: {},
  mounted() {
    this.tabChange(0)
  },
  methods: {
    tabChange(active) {
        this.active = active
        this.getList(active)
    },
    getList(active) {
      if(active == 0) {
        this.newList = this.scrollData;
      } else if(active == 1) {
        this.newList = this.scrollData.filter((item)=>{
          return item.state == 0
        })  
      } else if(active == 2) {
        this.newList = this.scrollData.filter((item)=>{
          return item.state == 2
        })  
      } else if(active == 3) {
        this.newList = this.scrollData.filter((item)=>{
          return item.state == 1
        })  
      }       
    },
    // 工单详情
    workOrderDetails(e) {
      let obj = $(e.target).data('item')
      this.$refs.case.open(obj.orderNum);
      // Bus.$emit('openDetail', id)
      // this.$refs.case.open(data.id, data.img);

    }
  }
}
</script>

<style lang="less" scoped>
.swiper-container {
  height: 400px;
}

.swiper-slide {
  height: 180px !important;
}

.chunk_con {
  // height: calc(100% - 40px);
  height: 100%;
}

.warp-box {
  margin-top: 16px;
  height: 560px;
  overflow: hidden;
}

.warp {
  overflow: hidden;
  height: 560px;
}

.latest_case {
  width: 100%;
  // background: rgba(31, 73, 135, 0.25);
  background: rgba(28,255,252,0.08);
  margin-top: 20px;

  // border: 1px solid rgba(35, 104, 255, 0.25);
  .latest_case_title {
    width: 100%;
    height: 40px;
    // background: rgba(31, 73, 135, 0.8);
    border: 1px solid rgba(35, 104, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 14px 0 18px;
    border: 1px solid #00B6D1;

   

    p:nth-child(1) {
      height: 20px;
      // padding: 0 12px;
      // background: #35cfe8;
      // border-radius: 10px 10px 10px 0px;
      font-size: 14px;
      font-family: Source Han Sans CN;
      font-weight: 600;
      color: #EFF6FF;
      line-height: 20px;
    }

    p:nth-child(2) {
      height: 20px;
      font-size: 14px;
      font-family: Source Han Sans SC;
      font-weight: 600;
      color: #EFF6FF;
      line-height: 20px;
      padding-left: 34px;
    }
  }

  .latest_case_text {
    width: 100%;
    padding: 16px 14px 13px 18px;
    max-height: 64px;
    overflow: hidden;
    font-size: 14px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #EFF6FF;
    line-height: 22px;
    word-wrap: break-word;
  }

  .latest_case_weizhi {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 14px 16px 18px;
    

    p:nth-child(1) {
      font-size: 14px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #EFF6FF;
    }

    p:nth-child(2) {
      height: 28px;
      line-height: 28px;
      background: rgba(31, 73, 135, 0.3);
      border-radius: 13px;
      font-size: 14px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      padding: 0 10px;
      z-index: 99;
      border: 1px solid #24DCF7;

      span {
        color: #ffffff;
        cursor: pointer;
      }
    }
  }
}

.state {
        display: inline-block;
        width: 11px;
        height: 11px;
        border-radius: 50%;
        margin-right: 10px;
      }
      .state1 {
        background: #43CC22;
      }
      .state2 {
        background: #FF5A3A;
      }
      .state3 {
        background: #FFC03A;
      }

.shichangjiandu {
  .summary {
    .title {
      border-bottom: 1px solid rgba(255, 255, 255, 0.4);
      position: relative;
      height: 42px;

      ::after {
        content: '';
        height: 1px;
        width: 7px;
        position: absolute;
        left: 0;
        bottom: 0;
        background: #fff;
      }

      .title-icon {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        font-size: 18px;
        font-weight: bold;
        color: #FFFFFF;

        img {
          width: 42px;
          height: 42px;
        }

        span {
          display: inline-block;
          height: 42px;
          line-height: 42px;
        }
      }

      .title-bg {
        display: flex;
        justify-content: flex-end;
        align-items: center;

        img {
          width: 227px;
          height: 10px;
        }

      }

      >div {
        width: 50%;
      }

    }

    .summary-content {
      width: 100%;
      padding-top: 16px;
      height: auto;
      .title2 {
        margin: 0 10px;
      }
    }
  }
}</style>
